﻿<Page x:Class="PresentationProject.Pages.GeographyClass.ClassPage2"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:PresentationProject"
      xmlns:tools="clr-namespace:_3DTools"
      mc:Ignorable="d" 
      d:DesignHeight="700" d:DesignWidth="1300"
      Background="Black"
	  Title="ClassPage2" x:Name="classPage2">
    <Page.Resources>
        <local:SphereMeshGenerator x:Key="sphere" Center="0 0 0 " Radius="1.2" Stacks="32" Slices="64"/>
    </Page.Resources>
    <Page.Triggers>
        <EventTrigger RoutedEvent="Page.Loaded">
            <BeginStoryboard>
                <Storyboard x:Name="story1">
                    <Point3DAnimationUsingKeyFrames Storyboard.TargetName="cam" Storyboard.TargetProperty="Position">
                        <SplinePoint3DKeyFrame KeyTime="0:0:0" Value="0 -3 50" />
                        <SplinePoint3DKeyFrame KeyTime="0:0:1.5" KeySpline="0.00,0.00 0.00,0.30" Value="0 -1 28" />
                        <SplinePoint3DKeyFrame KeyTime="0:0:3" KeySpline="0.00,0.00 0.30,0.00" Value="0 0 6" />
                    </Point3DAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="YRotate" Storyboard.TargetProperty="Angle">
                        <SplineDoubleKeyFrame KeyTime="0:0:0" Value="600" />
                        <SplineDoubleKeyFrame KeyTime="0:0:1.5" Value="300" />
                        <SplineDoubleKeyFrame KeyTime="0:0:3" KeySpline="0.00,0.00 0.00,0.10" Value="20" />
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>

    </Page.Triggers>
    <Grid>
        <tools:TrackballDecorator >
            <tools:Interactive3DDecorator >
            <Viewport3D x:Name="viewport" >
                <Viewport3D.Camera>
                    <PerspectiveCamera x:Name="cam" Position="0,0,50" LookDirection="0,0,-6" UpDirection="0,1,0">
                        <PerspectiveCamera.Transform>
                            <TranslateTransform3D x:Name="earthoffset" OffsetZ="0">
                            </TranslateTransform3D>
                        </PerspectiveCamera.Transform>
                    </PerspectiveCamera>

                </Viewport3D.Camera>

                    <ModelUIElement3D x:Name="earthmodel" >
                    <ModelUIElement3D.Model>
                        <GeometryModel3D Geometry ="{Binding Source={StaticResource sphere},
                                               Path=Geometry}">
                            <GeometryModel3D.Material>
                                <DiffuseMaterial>
                                    <DiffuseMaterial.Brush>
                                        <ImageBrush ImageSource="/Resources/Images/earthmap.jpg"/>
                                    </DiffuseMaterial.Brush>
                                </DiffuseMaterial>
                            </GeometryModel3D.Material>
                            <GeometryModel3D.Transform>
                                <RotateTransform3D >
                                    <RotateTransform3D.Rotation>
                                        <AxisAngleRotation3D x:Name="YRotate" Angle="0" Axis="-1,5,1" />
                                    </RotateTransform3D.Rotation>
                                </RotateTransform3D>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                    </ModelUIElement3D.Model>

                </ModelUIElement3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <Model3DGroup>
                            <AmbientLight Color="#404040"/>
                            <!--<DirectionalLight Color="#C0C0C0" Direction="2,-3,-1" />-->
                            <PointLight Color="#C0C0C0" Position="0,0,1000" />
                         </Model3DGroup>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
            </Viewport3D>
            </tools:Interactive3DDecorator>
        </tools:TrackballDecorator>
    </Grid>
</Page>
